<%@ page import="java.util.ArrayList" %>
<%@ page import="com.po.GoodsSingle" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    ArrayList goodslist = (ArrayList) session.getAttribute("goodslist");
%>
<html>
<head>
    <title>丽痕书店-魔法改变世界</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<style type="text/css">
    body{
        padding:10px;
    }
    th{
        text-align: center;
    }
</style>
<body>
    <div class="container">
        <table class="table table-bordered table-hover form-control table-striped">
            <thead>
            <tr height="50">
                <th colspan="3" align="center"><FONT style="FONT-SIZE: 30pt" face=华文行楷 class="text-primary">丽 痕 书 店</FONT></th>
            </tr>
            <tr class="info" align="center" height="30">
                <th>名称</th>
                <th>价格(元/本)</th>
                <th>购买</th>
            </tr>
            </thead>
            <tbody>
            <%
                if(goodslist==null||goodslist.size()==0){
            %>
            <tr height="100"><td colspan="3" align="center">没有商品可显示</td> </tr>
            <%
            }
            else {
                for(int i=0;i<goodslist.size();i++){
                    GoodsSingle single = (GoodsSingle) goodslist.get(i);
            %>
            <tr height="50" align="center" >
                <td><%=single.getName()%></td>
                <td class="text-danger"><%=single.getPrice()%></td>
                <td><a class="btn btn-primary" onclick="JavaScript:sureBuy(this)" href="docart.jsp?action=buy&id=<%=i%>">购买</a> </td>
            </tr>
            <%
                    }
                }
            %>
            <tr height="50">
                <td align="center" colspan="3"><a  class="btn btn-large btn-success col-lg-12" href="shopcart.jsp">查看购物车</a> </td>
            </tr>
            </tbody>
        </table>
    </div>
<script type="text/javascript">
    function sureBuy(obj) {
        var td = obj.parentNode.parentNode.childNodes[1];

        var name = td.innerHTML;
        alert(name+" 购买成功!");
    }
</script>
</body>
</html>
